<template>
  <div class='regiment-detail first-box'>
    <Info :info="info"></Info>
    <GreyLine></GreyLine>
    <component :is="compinentName" @openNew="openNew" :data="joinData"></component>
  </div>
</template>
<script>
import Info from "./common/info";
import GreyLine from "../../common/line.vue";
import Open from "./common/open";
import Join from "./common/join";
export default {
  components: { Info, GreyLine, Open, Join },
  name: "",
  data() {
    return {
      info: {
        id: 1,
        img: require("../../../assets/img/hpmepage/sense/1.png"),
        title: "优惠专享 | 免费洗车",
        price: 1, //现价
        cost: 35, //原价
        time: "2018-06-01 10:00 ~ 12:30"
      },
      compinentName: "",
      joinData:[
        {
          id:1,
          place:"青山区",
          name:"张子龙",
          phone:"12345678912",
          people:2,
          allPeople:3
        }
      ]
    };
  },
  methods: {
    openNew() {
      this.compinentName = "Open";
    },
    getList() {
      var params = {
        collageId: sessionStorage.getItem("detailId"),
        userId: sessionStorage.getItem("userId"),
        latitude: 30.57, //维度
        longitude: 114.3 //经度
      };
      _g.apiPost("collage/selectJoinTeam.do", params).then(res => {
        this.info.id=res.data.aCollage.id
        this.info.img=res.data.aCollage.picture||"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1535004363524&di=d92df07bf7f8cc565633f83a1e567d13&imgtype=0&src=http%3A%2F%2Fimage.bitautoimg.com%2Fappimage%2Fmedia%2F20180121%2Fw1080_h620_85868a7df2194a43bf3497ed27e56cdf.jpeg"
        this.info.title=res.data.aCollage.name
        this.info.price=res.data.aCollage.price
        this.info.cost=res.data.aCollage.cose||12000
        this.info.time=_g.formatTime(res.data.aCollage.startTime)+" ~ "+_g.formatTime(res.data.aCollage.endTime)

        var goal=[]
        res.data.list.forEach(ele => {
            goal.push({
              id:ele.aTeam.id,
              place:ele.aTeam.address,
              name:ele.user.realName,
              phone:ele.user.phone,
              people:ele.aTeam.teamNum,
              allPeople:res.data.aCollage.teamMax,
            })
        });
        this.$set(this,"joinData",goal)
      });
    }
  },
  created() {
    var path = _g.getRouterPath(this);
    if (path == "/regiment/join") {
      this.compinentName = "Join";
    } else if (path == "/regiment/open") {
      this.compinentName = "Open";
    }
     this.getList()
  }
};
</script>
<style lang="scss" scoped>
.regiment-detail {
}
</style>